package test;

import javassist.SerialVersionUID;

import java.io.*;

public class SerializeTest3 implements Serializable {
    int a = 99;
    int b = 88;
    SerializeTest2 serializeTest2 = new SerializeTest2();
    private static final long serialVersionUID = 3L;


    public static void main(String[] args) throws Exception {
        write(new SerializeTest3());
        read();
    }

    public SerializeTest3() {
        System.out.println("cons");
    }

    public static void write(Object o) throws Exception {
        ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream("c:/a.ser"));
        out.writeObject(o);
        out.close();
    }

    public static void read() throws Exception {
        ObjectInputStream in = new ObjectInputStream(new FileInputStream("c:/a.ser"));
        System.out.println(in.readObject());
        in.close();
    }

    @Override
    public String toString() {
        return "SerializeTest3{" +
                "a=" + a +
                ", b=" + b +
                ", serializeTest2=" + serializeTest2 +
                '}';
    }
//
//    private void readObject(ObjectInputStream in) throws ClassNotFoundException, IOException {
//        System.out.println("readObject");
//        in.defaultReadObject();
//    }
//
//    private void writeObject(ObjectOutputStream out) throws IOException {
//        System.out.println("writeObject");
//        out.defaultWriteObject();
//
//    }
}
